home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 May (DVD) / Macworld Resource DVD May 2003.toast / Data / Software / Bonus / Database / mysql-max-3.23.55.sit / mysql-max-3.23.55-apple-darwi.1 / include / violite.h < prev   
Encoding:
C/C++ Source or Header  |  2003-01-21  |  3.0 KB  |  118 lines  |  [TEXT/CWIE]

  1. /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  2.    
  3.    This library is free software; you can redistribute it and/or
  4.    modify it under the terms of the GNU Library General Public
  5.    License as published by the Free Software Foundation; either
  6.    version 2 of the License, or (at your option) any later version.
  7.    
  8.    This library is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.    Library General Public License for more details.
  12.    
  13.    You should have received a copy of the GNU Library General Public
  14.    License along with this library; if not, write to the Free
  15.    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  16.    MA 02111-1307, USA */
  17.  
  18. /*
  19.  * Vio Lite.
  20.  * Purpose: include file for Vio that will work with C and C++
  21.  */
  22.  
  23. #ifndef vio_violite_h_
  24. #define    vio_violite_h_
  25.  
  26. #include "my_net.h"            /* needed because of struct in_addr */
  27.  
  28. #ifdef HAVE_VIO
  29. #include <Vio.h>                /* Full VIO interface */
  30. #else
  31.  
  32. /* Simple vio interface in C;  The functions are implemented in violite.c */
  33.  
  34. #ifdef    __cplusplus
  35. extern "C" {
  36. #endif /* __cplusplus */
  37.  
  38. #ifndef Vio_defined
  39. #define Vio_defined
  40. struct st_vio;                    /* Only C */
  41. typedef struct st_vio Vio;
  42. #endif
  43.  
  44. enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET,
  45.              VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL};
  46.  
  47. Vio*        vio_new(my_socket    sd,
  48.             enum enum_vio_type type,
  49.             my_bool        localhost);
  50. #ifdef __WIN__
  51. Vio*        vio_new_win32pipe(HANDLE hPipe);
  52. #endif
  53. void        vio_delete(Vio* vio);
  54.  
  55. /*
  56.  * vio_read and vio_write should have the same semantics
  57.  * as read(2) and write(2).
  58.  */
  59. int        vio_read(        Vio*        vio,
  60.                     gptr        buf,    int    size);
  61. int        vio_write(        Vio*        vio,
  62.                     const gptr    buf,
  63.                     int        size);
  64. /*
  65.  * Whenever the socket is set to blocking mode or not.
  66.  */
  67. int        vio_blocking(        Vio*        vio,
  68.                     my_bool        onoff);
  69. my_bool        vio_is_blocking(    Vio*        vio);
  70. /*
  71.  * setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible.
  72.  */
  73.   int        vio_fastsend(        Vio*        vio);
  74. /*
  75.  * setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible.
  76.  */
  77. int        vio_keepalive(        Vio*        vio,
  78.                     my_bool        onoff);
  79. /*
  80.  * Whenever we should retry the last read/write operation.
  81.  */
  82. my_bool        vio_should_retry(    Vio*        vio);
  83. /*
  84.  * When the workday is over...
  85.  */
  86. int        vio_close(        Vio*        vio);
  87. /*
  88.  * Short text description of the socket for those, who are curious..
  89.  */
  90. const char*    vio_description(    Vio*        vio);
  91.  
  92. /* Return the type of the connection */
  93.  enum enum_vio_type vio_type(Vio* vio);
  94.  
  95. /* Return last error number */
  96. int vio_errno(Vio *vio);
  97.  
  98. /* Get socket number */
  99. my_socket vio_fd(Vio *vio);
  100.  
  101. /*
  102.  * Remote peer's address and name in text form.
  103.  */
  104. my_bool vio_peer_addr(Vio * vio, char *buf);
  105.  
  106. /* Remotes in_addr */
  107.  
  108. void vio_in_addr(Vio *vio, struct in_addr *in);
  109.  
  110.   /* Return 1 if there is data to be read */
  111. my_bool vio_poll_read(Vio *vio,uint timeout);
  112.  
  113. #ifdef    __cplusplus
  114. }
  115. #endif
  116. #endif /* HAVE_VIO */
  117. #endif /* vio_violite_h_ */
  118.